#!/bin/sh

argv0=$0

while [ $# -gt 0 ]; do
	case "$1" in
	-s)
		export STEREO_SWAP=1;;
	
	-g)
		export STEREO_GREY=1;;

	-f)
		export STEREO_NOSDR=1;;

	-m)
		if [ -z "$2" ]; then
			echo "-m must be followed by the stereo presentation method" >&2
			exit 1
		fi
		if [ "$2" = sequential ]; then
			# stereowrap tries to enable vsync through OpenGL extensions if
			# available, but just in case let's also set a few known env-vars.
			export __GL_SYNC_TO_VBLANK=1	# <- for nvidia
		fi
		export STEREO_METHOD="$2"
		shift;;

	-h)
		echo "usage: $argv0 [options]"
		echo ' -s  swap left/right images'
		echo ' -g  convert to greyscale before combining'
		echo ' -f  use fixed-function pipeline, no shaders (will not work for some methods)'
		echo ' -m  choose stereo presentation method'
		exit 0;;
	
	-*)
		echo "unrecognized option: $1" >&2
		exit 1;;
	
	*)
		break;;
	esac

	shift
done

echo "-- stereowrap($STEREO_METHOD): $*"
LD_PRELOAD="libstereowrap.so $LD_PRELOAD" $*
